package com.example.demo.Controller;

import com.example.demo.Entity.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.Dao.UserRepository;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("User")
public class UserController {

    @Autowired
    private UserRepository userRepository;

    @RequestMapping("/getAllPerson")
    @ResponseBody
    public List<Person> findAllPerson(){
        List<Person> list = new ArrayList<Person>();
        list = (List<Person>) userRepository.findAll();
        return list;
    }

    @RequestMapping("/getByOpenId")
    @ResponseBody
    public Person getByOpenId (String openId){
        Person person = userRepository.findByOpenId(openId);
        return person;
    }


}
